package robocup.component.actions;

/**
 * A dash action, which has the effect of accelerating the player.
 */
public class DashAction
    extends Action {

  /**
   * The power, by which a player should be accelerated. Feasible values range
   * from SConf.MINPOWER to SConf.MAXPOWER, which usually are [-100,100].
   * Negative values indicate backward dashing.
   */
  private int _power;

  /**
   * Returns the actions string representation:
   * 
   * @return (dash &lt;power&gt;)
   */
  @Override
  public String toString() {

    final StringBuffer buf = new StringBuffer();
    buf.append("(dash ");
    buf.append(this._power);
    buf.append(")");
    return buf.toString();
  }

  /**
   * Constructor of DashAction
   * 
   * @param power
   *          A value of [-100,100]
   */
  public DashAction(
      final int power) {

    this._power = power;
    this._type = TYPE.DASH;
  }

  /**
   * An action is worth sending if it effects the world.
   */
  @Override
  public boolean isWorthSending() {

    return !(this._power == 0);
  }

  /**
   * @return Returns the power.
   */
  public int getPower() {

    return this._power;
  }

  /**
   * @param _power
   *          The _power to set.
   */
  public void setPower(final int _power) {

    this._power = _power;
  }
}
